package com.java.diagnostics.visualizer.gc.iseriessupport.parser;

import com.java.diagnostics.visualizer.data.SourceData;
import com.java.diagnostics.visualizer.exceptions.GCAndMemoryVisualizerException;
import com.java.diagnostics.visualizer.impl.factory.LogFactory;
import com.java.diagnostics.visualizer.parser.vgc.VGCParser;
import com.java.diagnostics.visualizer.properties.OutputProperties;
import com.java.diagnostics.visualizer.sources.Source;
import java.util.logging.Logger;

public class ISeriesVGCParser
  implements VGCParser
{
  private static final Logger TRACE = LogFactory.getTrace(ISeriesVGCParser.class);
  
  private final String className = getClass().getName();
  
  public boolean isParseableSource(Source source) throws GCAndMemoryVisualizerException {
    TRACE.entering(this.className, "isParseableSource");
    boolean answer = source.containsWithinReasonableDistanceOfStart("GC: ");
    TRACE.exiting(this.className, "isParseableSource");
    return answer;
  }
  
  public SourceData parse(Source source, OutputProperties properties)
    throws GCAndMemoryVisualizerException
  {
    TRACE.entering(this.className, "parse");
    SourceData sourceData = new InstanceISeriesVGCParser().parse(source, properties);
    
    TRACE.exiting(this.className, "parse");
    return sourceData;
  }
}
